package com.itheima.dao;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealMapper {

    void add(Setmeal setmeal);

    void SetmealAndCheckGroupAdd(@Param("setmealId") Integer setmealId,@Param("checkgroupIds") List<Integer> checkgroupIds);

    List<Setmeal> findPage(@Param("queryString") String queryString);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void delSetmealAndCheckgroup(@Param("id") Integer id);

    @Delete("delete from t_setmeal where id = #{id}")
    void delete(@Param("id") Integer id);

    @Select("Select * from t_setmeal where id = #{id}")
    Setmeal findById(@Param("id") Integer id);

    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id}")
    List<Integer> findSetmealAndCheckgroupById(@Param("id") Integer id);

    void edit(Setmeal setmeal);

    @Select("select * from t_setmeal")
    List<Setmeal> findSetmealALL();

    @Select("select * from t_setmeal where id = #{id}")
    Setmeal findSetmealWechatById(@Param("id") Integer id);

    @Select("select cg.* from t_checkgroup cg, t_setmeal_checkgroup scg where cg.id = scg.checkgroup_id and setmeal_id =#{id}")
    List<CheckGroup> findSetmealCheckgroupWechatById(@Param("id") Integer id);

    @Select("select ck.* from t_checkitem ck, t_checkgroup_checkitem tcc where ck.id =tcc.checkitem_id and checkgroup_id =#{id}")
    List<CheckItem> findSetmealCheckItemWechatById(@Param("id") Integer id);

    List<CheckItem> findCheckItemByCheckGroupIdBatch(@Param("checkGroupIds") List<Integer> checkGroupIds);
}
